//
//  vec3f.cpp
//  
//
//  Created by Gallienne Kevin on 03/10/13.
//
//

#include "vec3f.h"
#include <iostream>

using namespace std;

vec3f::vec3f(float a, float b, float c){
    _data[0] = a;
    _data[1] = b;
    _data[2] = c;
};

vec3f::vec3f(const vec3f& other){
         _data[0] = other.getX();
	 _data[1] = other.getY();
	 _data[2] = other.getZ();
};

const float& vec3f::getX() const{
  cout << "Vec3f: constant access request" << endl;
    return _data[0];
};
const float& vec3f::getY() const{
  cout << "Vec3f: constant access request" << endl;
    return _data[1];
};
const float& vec3f::getZ() const{
  cout << "Vec3f: constant access request" << endl;
  return _data[2];
};

float* vec3f::getData(){
    return _data;
};

void vec3f::setX(float a){
    _data[0] = a;
};

void vec3f::setY(float a){
    _data[1] = a;
};
void vec3f::setZ(float a){
    _data[2] = a;
};

float& vec3f::x(){
  cout << "Vec3f: read access request" << endl;
  return _data[0];
};
float& vec3f::y(){
  cout << "Vec3f: read  access request" << endl;
  return _data[1];
};
float& vec3f::z(){
  cout << "Vec3f: read  access request" << endl;
  return _data[2];
};

vec3f vec3f::operator+(const vec3f& a){
  vec3f res;
  res.x() = a.getX()+getX();
  res.y() = a.getY()+getY();
  res.z() = a.getZ()+getZ();
  return res;
};

vec3f vec3f::operator-(const vec3f& b){
  vec3f res;
  res.x() = getX()-b.getX();
  res.y() = getY()-b.getY();
  res.z() = getZ()-b.getZ();
  return res;
};
vec3f vec3f::operator*(const float f){
  vec3f res;
  res.x() = getX()*f;
  res.y() = getY()*f;
  res.z() = getZ()*f;
  return res;
};
vec3f vec3f::operator/(const float f){
  vec3f res;
  if(f==0)
  	return *this;
  res.x() = getX()/f;
  res.y() = getY()/f;
  res.z() = getZ()/f;
  return res;
};

const float& vec3f::operator[](const int b){
  return _data[b];
};
